Context switching allows several applications to share the same hardware for the appearance of concurrency. The context is the state or contents of a processor (or processing accelerator) at any point in time, and which may include the contents of the registers and other local memory on the processor as well as the program counters or pointers that indicate the progression of the processor in a program or task being performed. The switching may be between threads or processes. In the case of image processing, the context switching may be between imaging kernels, where each kernel is a program executed on blocks of pixel data less than the entire image. During context switching, the processor's progression on one kernel is stopped, the state for the kernel is saved in a memory. Then, the state from a different, second kernel or process is restored on the processor, and the point in the task for the second kernel is determined by a program counter for example, for the processor to continue to perform further work on that second kernel until progression for this second kernel also is stopped, saved, and replaced, and so on.
Context switching is usually either pre-emptive or cooperative. In pre-emptive context switching, the processor may enforce switching at certain times among kernels or processes for example. This, however, may include saving all of the current state (“all state”) without knowledge of what is actually needed. For image processing, this may include switching out the entire contents of a relatively large, local, random access memory (RAM), thereby raising the cost in time and power consumption to save the state for the context switch. In cooperative switching, an application or program may voluntarily give up its processor time. Thus, cooperative switching requires the owner (application or program) to voluntarily relinquish control. This may introduce unreliable quality of service (QOS) such that target bitrates or frame rates may not be met, which may be critical with real-time image processing for example. Thus, a more efficient context switching that meets quality of service targets is desired.